home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / PNL Libraries / MyDesktopDB.p < prev    next >
Encoding:
Text File  |  1995-10-22  |  1.6 KB  |  78 lines  |  [TEXT/CWIE]

  1. unit MyDesktopDB;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Files;
  7.  
  8.     function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
  9. { You can safely ignore the error and use the returned rn in calls to Get/Set, they will just bounce }
  10.     procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  11.     procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  12.  
  13. implementation
  14.  
  15.     uses
  16.         GestaltEqu;
  17.         
  18.     const
  19.         bad_rn = -1;
  20.  
  21.     function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
  22.         var
  23.             pb: DTPBRec;
  24.             oe: OSErr;
  25.             v: longInt;
  26.     begin
  27.         rn := bad_rn;
  28.         oe := Gestalt(gestaltDBAccessMgrAttr, v);
  29.         if (oe = noErr) & not BTST(v, gestaltDBAccessMgrPresent) then begin
  30.             oe := -1;
  31.         end;
  32.         if oe = noErr then begin
  33.             pb.ioNamePtr := nil;
  34.             pb.ioVRefNum := vrn;
  35.             oe := PBDTGetPath(@pb);
  36.             if oe = noErr then begin
  37.                 rn := pb.ioDTRefNum;
  38.             end;
  39.         end;
  40.         GetDesktopDB := oe;
  41.     end;
  42.  
  43.     procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  44.         var
  45.             pb: DTPBRec;
  46.             oe: OSErr;
  47.     begin
  48.         s := '';
  49.         if rn <> bad_rn then begin
  50.             pb.ioNamePtr := @fs.name;
  51.             pb.ioDTRefNum := rn;
  52.             pb.ioDTBuffer := @s[1];
  53.             pb.ioDirID := fs.parID;
  54.             oe := PBDTGetCommentSync(@pb);
  55.             if oe = noErr then begin
  56.                 s[0] := chr(pb.ioDTActCount);
  57.             end
  58.             else
  59.                 s := '';
  60.         end;
  61.     end;
  62.  
  63.     procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
  64.         var
  65.             pb: DTPBRec;
  66.             oe: OSErr;
  67.     begin
  68.         if rn <> bad_rn then begin
  69.             pb.ioNamePtr := @fs.name;
  70.             pb.ioDTRefNum := rn;
  71.             pb.ioDTBuffer := @s[1];
  72.             pb.ioDTReqCount := length(s);
  73.             pb.ioDirID := fs.parID;
  74.             oe := PBDTSetCommentSync(@pb);
  75.         end;
  76.     end;
  77.  
  78. end.